#include <stdio.h>
#include <stdlib.h>

/*
 * 二叉树
 */

typedef struct Bitnode
{
	char data;
	struct Bitnode *lchild, *rchild;
}Bitnode, *bitree;


void createbitree(bitree * t)
{
	char c;

	scanf("%c", &c);

	if (' ' == c) {
		*t = NULL;;
	}
	else {
		*t = (Bitnode *) malloc (sizeof(Bitnode));
		(*t)->data = c;
		createbitree(&(*t)->lchild);
		createbitree(&(*t)->rchild);
	}
}

void visit(char c, int level)
{
	printf("%c in %d ceng.\n", c, level);
}

void preorder_traverse(bitree t, int level)
{
	if (t) {
		visit(t->data, level);
		preorder_traverse(t->lchild, level + 1);
		preorder_traverse(t->rchild, level + 1);
	}
}

void main()
{
	int level  = 1;
	bitree t = NULL;

	createbitree(&t);
	preorder_traverse(t, level);
}

/*
				A
			/		\
		   /		 \
		  B			  C
		   \		 /
            \		/
			 D	   E 	

	ab d  ce三个空格 
	

 */

